#pragma once
#include<string>
#include <windows.h>

//xerces
//xml file parse enginnes
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/sax/HandlerBase.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/framework/LocalFileFormatTarget.hpp>
#include <xercesc/framework/StdOutFormatTarget.hpp>


class XStr 
{
public :
	XStr(const char* const toTranscode)
	{
		fUnicodeForm = xercesc::XMLString::transcode(toTranscode);
	}
	~XStr()
	{
		xercesc::XMLString::release(&fUnicodeForm);
	}
	const XMLCh* unicodeForm() const
	{
		return fUnicodeForm;
	}
	
private :
	XMLCh*	 fUnicodeForm;
};

#define X(str) XStr(str).unicodeForm()

//end xml prepare

class CTinyConfig
{
public:
	CTinyConfig(void);
public:
	virtual ~CTinyConfig(void);
public:
	std::string getRootFolder(void);
public:
	virtual std::string getConfigFileName(void) = 0;
public:
	virtual bool readConfigFile(std::string filename) =0;
	bool openXmlFile(std::string filename);
	bool closeXmLFile();
public:
	bool refreshConfig(void);
public:
	xercesc::DOMTreeWalker * m_walker;
	xercesc::DOMDocument * m_doc;
	xercesc::XercesDOMParser *m_parser;
	std::string m_InstanceName;
	int m_ModulePort;
	std::string m_ModuleIP;
	int m_logport;
	std::string m_logip;
	std::string m_DataBaseConnStr;
private:
	bool m_xmlInitlized;
};
